<?php

use Faker\Factory as Faker;
use App\Models\Navigate;
use App\Repositories\NavigateRepository;

trait MakeNavigateTrait
{
    /**
     * Create fake instance of Navigate and save it in database
     *
     * @param array $navigateFields
     * @return Navigate
     */
    public function makeNavigate($navigateFields = [])
    {
        /** @var NavigateRepository $navigateRepo */
        $navigateRepo = App::make(NavigateRepository::class);
        $theme = $this->fakeNavigateData($navigateFields);
        return $navigateRepo->create($theme);
    }

    /**
     * Get fake instance of Navigate
     *
     * @param array $navigateFields
     * @return Navigate
     */
    public function fakeNavigate($navigateFields = [])
    {
        return new Navigate($this->fakeNavigateData($navigateFields));
    }

    /**
     * Get fake data of Navigate
     *
     * @param array $postFields
     * @return array
     */
    public function fakeNavigateData($navigateFields = [])
    {
        $fake = Faker::create();

        return array_merge([
            'skip_type' => $fake->randomDigitNotNull,
            'skip_id' => $fake->randomDigitNotNull,
            'skip_url' => $fake->text,
            'image_name' => $fake->word,
            'image' => $fake->text,
            'sort' => $fake->randomDigitNotNull,
            'created_at' => $fake->word,
            'updated_at' => $fake->word
        ], $navigateFields);
    }
}
